package cn.ffcs.uec.view.util;

public class LoginAction{
/*implements InitializingBean
{
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private LdapService ldapServiceImpl;
@Autowired
private StaffLockDao staffLockDaoImpl;
@Autowired
private LogConsumer logConsumer;
@Autowired
private CommConfigService commConfigservice;
@Autowired
private SendSmsComponent sendSmsComponent;
@Autowired
private CacheUtil randomCodeCache;
private static final String AUTH_SERVER_IP = PropertiesUtil.getProp("auth_server_ip");
private static final int AUTH_SERVER_PORT = Integer.parseInt(PropertiesUtil.getProp("auth_server_port", "5556"));
private static final String AUTH_LICENSE_KEY = PropertiesUtil.getProp("auth_license_key");

public void afterPropertiesSet()
  throws Exception
{}

public Object authenticate(String user, String password, String checkCode, String clientId, HttpServletRequest req)
{
  long beginTime = System.currentTimeMillis();
  LdapStaffVo staff = null;
  HttpSession ss = req.getSession();
  Object[] r = null;
  String respMsg = null;
  String resultStatus = SystemLog.Result.FAILURE.getDesc();
  String staffUuid = null;
  FlumeLogBase.SuccessFlag flumeFlag = FlumeLogBase.SuccessFlag.SUCCESS;
  String flumeErrorMsg = null;
  long sampleTime6 = 0L;
  boolean isOpenTimeSwitch = false;
  try
  {
    isOpenTimeSwitch = this.commConfigservice.isOpenSwitch("loginIsOpenTimeSwitch");
    long sampleTime1 = System.currentTimeMillis();
    
    String key = req.getHeader("rnd");
    checkCode = JavaScriptCryptUtil.jsTripleDesDecrypt(checkCode, key);
    clientId = JavaScriptCryptUtil.jsTripleDesDecrypt(clientId, key);
    password = JavaScriptCryptUtil.jsTripleDesDecrypt(password, key);
    String originalPwd = password;
    user = JavaScriptCryptUtil.jsTripleDesDecrypt(user, key);
    
    long sampleTime2 = System.currentTimeMillis();
    if (isOpenTimeSwitch) {
      this.logger.error("[账号密码登录]解密请求参数=" + (sampleTime2 - sampleTime1));
    }
    String cc = (String)ss.getAttribute("check-code-normal");
    this.logger.error("user:" + user + " post checkCode=" + checkCode + ",session:check-code-normal got:" + cc);
    
    ss.removeAttribute("check-code-normal");
    this.logger.info("session:check-code-normal removed");
    boolean isCheckCodeFlag = this.commConfigservice.isOpenSwitch("LOGIN_CHECKCODE_ENABLE");
    if (isCheckCodeFlag)
    {
      if ((!"9876".equals(checkCode)) && (!checkCode.equals(cc)))
      {
        respMsg = "验证码不正确！";
        flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
        flumeErrorMsg = "验证码不正确！";
        long sampleTime9;
        CommonSystemLog log;
        return AjaxUtil.createReturnValueError(new Object[] { "验证码不正确！" });
      }
    }
    else if (!checkCode.equals(cc))
    {
      respMsg = "验证码不正确！";
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "验证码不正确！";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "验证码不正确！" });
    }
    long sampleTime3 = System.currentTimeMillis();
    if (isOpenTimeSwitch) {
      this.logger.error("[账号密码登录]验证随机码=" + (sampleTime3 - sampleTime2));
    }
    if (user != null) {
      staff = this.ldapServiceImpl.loadStaffByAccount(user);
    }
    long sampleTime4 = System.currentTimeMillis();
    if (isOpenTimeSwitch) {
      this.logger.error("[账号密码登录]查询员工信息=" + (sampleTime4 - sampleTime3));
    }
    if (staff == null)
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "用户不存在！";
      respMsg = "用户不存在！";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "用户名或者密码错误!" });
    }
    staffUuid = staff.getUuid();
    if (this.staffLockDaoImpl.isStaffLocked(staff.getUuid()))
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "您的帐号已被锁定,请使用\"忘记密码\"功能";
      respMsg = "您的帐号已被锁定,请使用\"忘记密码\"功能";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValue("locked", new Object[] { "您的帐号已被锁定,请使用\"忘记密码\"功能" });
    }
    long sampleTime5 = System.currentTimeMillis();
    if (isOpenTimeSwitch) {
      this.logger.error("[账号密码登录]账号是否锁定=" + (sampleTime5 - sampleTime4));
    }
    if (StringUtils.isEmpty(staff.getUserPassord()))
    {
      flumeFlag = FlumeLogBase.SuccessFlag.SUCCESS;
      flumeErrorMsg = "用户初始密码为空,引导致密码修改页面";
      respMsg = "密码为空,请初始化密码";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValue("null-password", new Object[] { "密码为空，请初始化密码!" });
    }
    try
    {
      password = SimpleDESCry.encry(password);
    }
    catch (Exception e)
    {
      respMsg = "密码解密异常";
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "密码解密异常";
      arrayOfObject1 = AjaxUtil.createReturnValueError(new Object[] { "密码解密异常" });
      long sampleTime9 = System.currentTimeMillis();
      CommonSystemLog log = new CommonSystemLog();
      log.setServiceCode(SystemLog.ServiceCode.EAM130009.getCode());
      log.setServiceName(SystemLog.ServiceCode.EAM130009.getDesc());
      log.setAuthType("1");
      log.setRequestTime(new Date(beginTime));
      log.setResponseTime(new Date());
      log.setConsumeTime(Long.valueOf(System.currentTimeMillis() - beginTime));
      log.setRequestIp(GetipUtil.getIpAddr(req));
      if ((r != null) && (SystemLog.Result.SUCCESS.getDesc().equals(resultStatus))) {
        log.setOrgUuid((String)r[2]);
      }
      log.setStaffAccount(user);
      log.setStaffUuid(staffUuid);
      log.setResultStatus(resultStatus);
      log.setClientCode(clientId);
      log.setRequestContent("user:" + user + "|password:" + password + "|checkCode:" + checkCode);
      log.setResponseContent(respMsg);
      log.setUserAgent(req.getHeader("User-Agent"));
      log.setSessionId(ss.getId());
      log.setLocalHost(GetipUtil.LOCAL_HOST);
      this.logConsumer.addLogToQueue(log);
      FlumeLogUtil.writeFlumeLog(FlumeLogUtil.buildInterfaceLog(log, flumeFlag, flumeErrorMsg, SystemLog.ServiceCode.EAM130009));
      if (isOpenTimeSwitch) {
        this.logger.error("[账号密码登录]查询组织耗时=" + (System.currentTimeMillis() - sampleTime9));
      }
      return arrayOfObject1;
    }
    if (!password.equals(staff.getUserPassord()))
    {
      boolean locked = this.staffLockDaoImpl.loginFailed(staff.getUuid(), staff.getStaffAccount());
      if (locked)
      {
        flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
        flumeErrorMsg = "您的帐号已被锁定,请使用\"忘记密码\"功能";
        respMsg = "您的帐号已被锁定,请使用\"忘记密码\"功能";
        long sampleTime9;
        CommonSystemLog log;
        return AjaxUtil.createReturnValue("locked", new Object[] { "您的帐号已被锁定,请使用\"忘记密码\"功能" });
      }
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "密码错误！";
      respMsg = "密码错误！";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "用户名或者密码错误!" });
    }
    this.staffLockDaoImpl.loginSuccessed(staff.getUuid());
    sampleTime6 = System.currentTimeMillis();
    if (isOpenTimeSwitch) {
      this.logger.error("[账号密码登录]删除登录失败记录=" + (sampleTime6 - sampleTime5));
    }
    if ((StaffPwdCheckUtil.isEnableLoginWeakPwdChk()) && (!PwdPolicyUtil.isMatchBasicPattern(originalPwd)))
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "密码不符合要求";
      respMsg = "密码不符合要求";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValue("weak-pwd", new Object[] { "密码不符合要求" });
    }
    if (StaffPwdCheckUtil.isEnableStaffPwdForceModifyCheck()) {
      if (StaffPwdCheckUtil.countPwdLogByAccount(user) == 0L)
      {
        initPwdModifyLog(staff);
      }
      else if (StaffPwdCheckUtil.isNeedModifyPwd(user))
      {
        String msg = String.format("您的密码已%d天未变更，请通过点击“忘记/修改密码”更改密码后再登录", new Object[] { Integer.valueOf(StaffPwdCheckUtil.getPwdForceModifyCheckPeriod()) });
        flumeFlag = FlumeLogBase.SuccessFlag.SUCCESS;
        respMsg = msg;
        flumeErrorMsg = msg;
        long sampleTime9;
        CommonSystemLog log;
        return AjaxUtil.createReturnValue("pwd-force-modify", new Object[] { msg });
      }
    }
    long sampleTime7 = System.currentTimeMillis();
    if (isOpenTimeSwitch) {
      this.logger.error("[账号密码登录]密码是否强制修改耗时=" + (sampleTime7 - sampleTime6));
    }
    r = processWithStaff(staff, ss);
    long sampleTime8 = System.currentTimeMillis();
    if (isOpenTimeSwitch) {
      this.logger.error("[账号密码登录]查询组织耗时=" + (sampleTime8 - sampleTime7));
    }
    if (((Boolean)r[0]).booleanValue())
    {
      respMsg = "登录成功";
      resultStatus = SystemLog.Result.SUCCESS.getDesc();
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueSuccess(new Object[] { r[1] });
    }
    flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
    flumeErrorMsg = (String)r[1];
    respMsg = (String)r[1];
    long sampleTime9;
    CommonSystemLog log;
    return AjaxUtil.createReturnValueError(new Object[] { r[1] });
  }
  catch (Exception e)
  {
    Object[] arrayOfObject1;
    e.printStackTrace();
    flumeFlag = FlumeLogBase.SuccessFlag.EXCEPTION;
    flumeErrorMsg = e.getMessage();
    respMsg = e.getMessage();
    long sampleTime9;
    CommonSystemLog log;
    return AjaxUtil.createReturnValueError();
  }
  finally
  {
    long sampleTime9 = System.currentTimeMillis();
    CommonSystemLog log = new CommonSystemLog();
    log.setServiceCode(SystemLog.ServiceCode.EAM130009.getCode());
    log.setServiceName(SystemLog.ServiceCode.EAM130009.getDesc());
    log.setAuthType("1");
    log.setRequestTime(new Date(beginTime));
    log.setResponseTime(new Date());
    log.setConsumeTime(Long.valueOf(System.currentTimeMillis() - beginTime));
    log.setRequestIp(GetipUtil.getIpAddr(req));
    if ((r != null) && (SystemLog.Result.SUCCESS.getDesc().equals(resultStatus))) {
      log.setOrgUuid((String)r[2]);
    }
    log.setStaffAccount(user);
    log.setStaffUuid(staffUuid);
    log.setResultStatus(resultStatus);
    log.setClientCode(clientId);
    log.setRequestContent("user:" + user + "|password:" + password + "|checkCode:" + checkCode);
    log.setResponseContent(respMsg);
    log.setUserAgent(req.getHeader("User-Agent"));
    log.setSessionId(ss.getId());
    log.setLocalHost(GetipUtil.LOCAL_HOST);
    this.logConsumer.addLogToQueue(log);
    FlumeLogUtil.writeFlumeLog(FlumeLogUtil.buildInterfaceLog(log, flumeFlag, flumeErrorMsg, SystemLog.ServiceCode.EAM130009));
    if (isOpenTimeSwitch) {
      this.logger.error("[账号密码登录]查询组织耗时=" + (System.currentTimeMillis() - sampleTime9));
    }
  }
}

public Integer querySmsSendInterval(HttpServletRequest request)
{
  return Integer.valueOf(this.sendSmsComponent.getSMSSendInterval());
}

public Object sendSmsCode(String phoneNumber, HttpServletRequest req)
{
  try
  {
    String key = req.getHeader("rnd");
    phoneNumber = JavaScriptCryptUtil.jsTripleDesDecrypt(phoneNumber, key);
    

    HttpSession ss = req.getSession();
    
    int count = this.ldapServiceImpl.countStaffByMobilePhone(phoneNumber);
    if (count == 0) {
      return AjaxUtil.createReturnValueError(new Object[] { "手机号错误或者无对应员工！" });
    }
    if (count > 1) {
      return AjaxUtil.createReturnValueError(new Object[] { "此手机号对应多个用户,不能用动态认证" });
    }
    LdapStaffVo staff = this.ldapServiceImpl
      .loadUniqueStaffByMobilePhone(phoneNumber);
    ss.setAttribute("PHONE_NUMBER", 
      phoneNumber);
    ss.setAttribute("PHONE_STAFF", staff);
    

    String randCode = String.format("%06d", new Object[] {
      Integer.valueOf(RandomUtils.nextInt(1000000)) });
    this.logger.error("sms-code:" + randCode);
    
    String oraRandomSms = "";
    oraRandomSms = this.commConfigservice.getSwitchCode(AuthConstants.RAMDOM_SMS);
    if (StrUtil.isEmpty(oraRandomSms))
    {
      this.logger.debug("短息内容为空");
      return AjaxUtil.createReturnValueError(new Object[] { "发送短信验证码失败！" });
    }
    String randomSms = oraRandomSms.replace("randCode", randCode);
    
    SMSSendRecord record = new SMSSendRecord(null, null, phoneNumber, new Date(), null);
    String sendFrequencyPrompt = this.sendSmsComponent.smsSendFrequencyCheck(record);
    if (sendFrequencyPrompt != null) {
      return AjaxUtil.createReturnValueError(new Object[] { sendFrequencyPrompt });
    }
    if (!this.sendSmsComponent.sendSmsByOip(phoneNumber, staff.getStaffAccount(), randomSms, "短信认证")) {
      return AjaxUtil.createReturnValueError(new Object[] { "发送短信验证码失败！" });
    }
    record.setSmsCode(randCode);
    record.setRequestIp(GetipUtil.getIpAddr(req));
    this.sendSmsComponent.saveSMSSendRecord(record);
    ss.setAttribute("SMS_CODE", randCode);
    ss.setAttribute("SMS_CODE_TIMESTAMP", 
      Long.valueOf(System.currentTimeMillis()));
    return AjaxUtil.createReturnValueSuccess(new Object[0]);
  }
  catch (Exception e)
  {
    e.printStackTrace();
  }
  return AjaxUtil.createReturnValueError();
}

public Object sendSmsCodeByStaffAccount(String account, HttpServletRequest req)
{
  try
  {
    StringBuffer sb = new StringBuffer(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 进入后台action,开始执行sendSmsCode方法");
    sb.append("\n");
    
    String key = req.getHeader("rnd");
    
    account = JavaScriptCryptUtil.jsTripleDesDecrypt(account, key);
    
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 手机号码校验开始");
    sb.append("\n");
    LdapStaffVo staff = this.ldapServiceImpl.loadStaffByAccount(account);
    if (staff == null) {
      return AjaxUtil.createReturnValueError(new Object[] { "账号不存在或密码错误" });
    }
    boolean locked = this.staffLockDaoImpl.isStaffLocked(staff.getUuid());
    String isForUnlock = req.getHeader("isForUnlock");
    if ((locked) && (!"true".equals(isForUnlock))) {
      return AjaxUtil.createReturnValue("locked", new Object[] { "您的帐号已被锁定,请使用\"快速解锁\"功能" });
    }
    String phoneNumber = staff.getMobilePhone();
    if ((phoneNumber == null) || ("".equals(phoneNumber))) {
      return AjaxUtil.createReturnValueError(new Object[] { "该员工在内部认证没有手机号！" });
    }
    HttpSession ss = req.getSession();
    
    ss.setAttribute("PHONE_NUMBER", 
      phoneNumber);
    ss.setAttribute("PHONE_STAFF", staff);
    

    String randCode = String.format("%06d", new Object[] {
      Integer.valueOf(RandomUtils.nextInt(1000000)) });
    this.logger.error("sms-code:" + randCode);
    

    String oraRandomSms = "";
    oraRandomSms = this.commConfigservice.getSwitchCode(AuthConstants.RAMDOM_SMS);
    if (StrUtil.isEmpty(oraRandomSms))
    {
      this.logger.debug("短息内容为空");
      return AjaxUtil.createReturnValueError(new Object[] { "发送短信验证码失败！" });
    }
    String randomSms = oraRandomSms.replace("randCode", randCode);
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 手机号码校验结束");
    sb.append("\n");
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 手机号码短信发送间隔校验开始");
    sb.append("\n");
    
    SMSSendRecord record = new SMSSendRecord(null, null, phoneNumber, new Date(), null);
    String sendFrequencyPrompt = this.sendSmsComponent.smsSendFrequencyCheck(record);
    if (sendFrequencyPrompt != null) {
      return AjaxUtil.createReturnValueError(new Object[] { sendFrequencyPrompt });
    }
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 手机号码短信发送间隔校验结束");
    sb.append("\n");
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 短信发送开始");
    sb.append("\n");
    if (!sendSmsByOip(sb, phoneNumber, staff.getStaffAccount(), randomSms, "短信认证")) {
      return AjaxUtil.createReturnValueError(new Object[] { "发送短信验证码失败！" });
    }
    if ("true".equals(isForUnlock)) {
      this.randomCodeCache.putObjectInCache(account, randCode);
    }
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 短信发送结束");
    sb.append("\n");
    record.setSmsCode(randCode);
    record.setRequestIp(GetipUtil.getIpAddr(req));
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 添加短信发送间隔日志开始");
    sb.append("\n");
    this.sendSmsComponent.saveSMSSendRecord(record);
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 添加短信发送间隔日志结束");
    sb.append("\n");
    ss.setAttribute("SMS_CODE", randCode);
    ss.setAttribute("SMS_CODE_TIMESTAMP", 
      Long.valueOf(System.currentTimeMillis()));
    StringBuilder sbp = new StringBuilder(phoneNumber);
    sbp.replace(3, 7, "****");
    SMSSendRecordAll recordAll = new SMSSendRecordAll();
    BeanUtils.copyProperties(recordAll, record);
    recordAll.setIntfTime(sb.toString());
    this.sendSmsComponent.saveSMSSendRecord2(recordAll);
    return AjaxUtil.createReturnValueSuccess(new Object[] { sbp.toString() });
  }
  catch (Exception e)
  {
    e.printStackTrace();
  }
  return AjaxUtil.createReturnValueError();
}

public Object sendSmsCodeByStaffAccountPassword(String account, String password, HttpServletRequest req)
{
  try
  {
    StringBuffer sb = new StringBuffer(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 进入后台action,开始执行sendSmsCode方法");
    sb.append("\n");
    
    String key = req.getHeader("rnd");
    
    account = JavaScriptCryptUtil.jsTripleDesDecrypt(account, key);
    password = JavaScriptCryptUtil.jsTripleDesDecrypt(password, key);
    
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 手机号码校验开始");
    sb.append("\n");
    LdapStaffVo staff = this.ldapServiceImpl.loadStaffByAccount(account);
    if (staff == null) {
      return AjaxUtil.createReturnValueError(new Object[] { "账号或密码错误" });
    }
    boolean locked = this.staffLockDaoImpl.isStaffLocked(staff.getUuid());
    String isForUnlock = req.getHeader("isForUnlock");
    if ((locked) && (!"true".equals(isForUnlock))) {
      return AjaxUtil.createReturnValue("locked", new Object[] { "您的帐号已被锁定,请使用\"快速解锁\"功能" });
    }
    password = SimpleDESCry.encry(password);
    if (!password.equals(staff.getUserPassord()))
    {
      this.staffLockDaoImpl.loginFailed(staff.getUuid(), 
        staff.getStaffAccount());
      return AjaxUtil.createReturnValueError(new Object[] { "账号或密码错误" });
    }
    String phoneNumber = staff.getMobilePhone();
    if ((phoneNumber == null) || ("".equals(phoneNumber))) {
      return AjaxUtil.createReturnValueError(new Object[] { "该员工在内部认证没有手机号！" });
    }
    HttpSession ss = req.getSession();
    
    ss.setAttribute("PHONE_NUMBER", 
      phoneNumber);
    ss.setAttribute("PHONE_STAFF", staff);
    

    String randCode = String.format("%06d", new Object[] {
      Integer.valueOf(RandomUtils.nextInt(1000000)) });
    this.logger.error("sms-code:" + randCode);
    

    String oraRandomSms = "";
    oraRandomSms = this.commConfigservice.getSwitchCode(AuthConstants.RAMDOM_SMS);
    if (StrUtil.isEmpty(oraRandomSms))
    {
      this.logger.debug("短息内容为空");
      return AjaxUtil.createReturnValueError(new Object[] { "发送短信验证码失败！" });
    }
    String randomSms = oraRandomSms.replace("randCode", randCode);
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 手机号码校验结束");
    sb.append("\n");
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 手机号码短信发送间隔校验开始");
    sb.append("\n");
    
    SMSSendRecord record = new SMSSendRecord(null, null, phoneNumber, new Date(), null);
    String sendFrequencyPrompt = this.sendSmsComponent.smsSendFrequencyCheck(record);
    if (sendFrequencyPrompt != null) {
      return AjaxUtil.createReturnValueError(new Object[] { sendFrequencyPrompt });
    }
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 手机号码短信发送间隔校验结束");
    sb.append("\n");
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 短信发送开始");
    sb.append("\n");
    if (!sendSmsByOip(sb, phoneNumber, staff.getStaffAccount(), randomSms, "短信认证")) {
      return AjaxUtil.createReturnValueError(new Object[] { "发送短信验证码失败！" });
    }
    if ("true".equals(isForUnlock)) {
      this.randomCodeCache.putObjectInCache(account, randCode);
    }
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 短信发送结束");
    sb.append("\n");
    record.setSmsCode(randCode);
    record.setRequestIp(GetipUtil.getIpAddr(req));
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 添加短信发送间隔日志开始");
    sb.append("\n");
    this.sendSmsComponent.saveSMSSendRecord(record);
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 添加短信发送间隔日志结束");
    sb.append("\n");
    ss.setAttribute("SMS_CODE", randCode);
    ss.setAttribute("SMS_CODE_TIMESTAMP", 
      Long.valueOf(System.currentTimeMillis()));
    StringBuilder sbp = new StringBuilder(phoneNumber);
    sbp.replace(3, 7, "****");
    SMSSendRecordAll recordAll = new SMSSendRecordAll();
    BeanUtils.copyProperties(recordAll, record);
    recordAll.setIntfTime(sb.toString());
    this.sendSmsComponent.saveSMSSendRecord2(recordAll);
    return AjaxUtil.createReturnValueSuccess(new Object[] { sbp.toString() });
  }
  catch (Exception e)
  {
    e.printStackTrace();
  }
  return AjaxUtil.createReturnValueError();
}

public Object smsAuthenticate(String phoneNumber, String smsCode, String checkCode, String clientId, HttpServletRequest req)
{
  long beginTime = System.currentTimeMillis();
  LdapStaffVo staff = null;
  HttpSession ss = req.getSession();
  Object[] r = null;
  String respMsg = null;
  String resultStatus = SystemLog.Result.FAILURE.getDesc();
  String staffAccount = null;
  String staffUuid = null;
  FlumeLogBase.SuccessFlag flumeFlag = FlumeLogBase.SuccessFlag.SUCCESS;
  String flumeErrorMsg = null;
  try
  {
    String key = req.getHeader("rnd");
    phoneNumber = JavaScriptCryptUtil.jsTripleDesDecrypt(phoneNumber, key);
    smsCode = JavaScriptCryptUtil.jsTripleDesDecrypt(smsCode, key);
    clientId = JavaScriptCryptUtil.jsTripleDesDecrypt(clientId, key);
    

    String prevPhoneNumber = (String)ss
      .getAttribute("PHONE_NUMBER");
    staff = (LdapStaffVo)ss
      .getAttribute("PHONE_STAFF");
    if (staff != null)
    {
      staffAccount = staff.getStaffAccount();
      staffUuid = staff.getUuid();
    }
    if (prevPhoneNumber == null)
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "请先获取短信验证码！";
      respMsg = "请先获取短信验证码！";
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "请先获取短信验证码！" });
    }
    if (!phoneNumber.equals(prevPhoneNumber))
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "输入的手机号码不一致！";
      respMsg = "输入的手机号码不一致！";
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "输入的手机号码不一致！" });
    }
    String prevSmsCode = (String)ss
      .getAttribute("SMS_CODE");
    if (prevSmsCode == null)
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "请先获取短信验证码！";
      respMsg = "请先获取短信验证码！";
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "请先获取短信验证码！" });
    }
    long scTime = ((Long)ss
      .getAttribute("SMS_CODE_TIMESTAMP")).longValue();
    if (System.currentTimeMillis() - scTime > 300000L)
    {
      respMsg = "短信验证码的有效期已过，请重新获取！";
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "短信验证码的有效期已过，请重新获取！";
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "短信验证码的有效期已过，请重新获取！" });
    }
    if (!smsCode.equals(prevSmsCode))
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "短信验证码有误！";
      respMsg = "短信验证码有误！";
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "短信验证码有误！" });
    }
    ss.removeAttribute("SMS_CODE");
    
    r = processWithStaff(staff, ss);
    if (((Boolean)r[0]).booleanValue())
    {
      resultStatus = SystemLog.Result.SUCCESS.getDesc();
      respMsg = "登录成功";
      CommonSystemLog log;
      return AjaxUtil.createReturnValueSuccess(new Object[] { r[1] });
    }
    flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
    flumeErrorMsg = (String)r[1];
    respMsg = (String)r[1];
    CommonSystemLog log;
    return AjaxUtil.createReturnValueError(new Object[] { r[1] });
  }
  catch (Exception e)
  {
    Object[] arrayOfObject1;
    flumeFlag = FlumeLogBase.SuccessFlag.EXCEPTION;
    flumeErrorMsg = e.getMessage();
    e.printStackTrace();
    respMsg = e.getMessage();
    CommonSystemLog log;
    return AjaxUtil.createReturnValueError();
  }
  finally
  {
    CommonSystemLog log = new CommonSystemLog();
    log.setServiceCode(SystemLog.ServiceCode.EAM130011.getCode());
    log.setServiceName(SystemLog.ServiceCode.EAM130011.getDesc());
    log.setAuthType("5");
    log.setRequestTime(new Date(beginTime));
    log.setResponseTime(new Date());
    log.setConsumeTime(Long.valueOf(System.currentTimeMillis() - beginTime));
    log.setRequestIp(GetipUtil.getIpAddr(req));
    if ((r != null) && (SystemLog.Result.SUCCESS.getDesc().equals(resultStatus))) {
      log.setOrgUuid((String)r[2]);
    }
    log.setStaffAccount(staffAccount);
    log.setStaffUuid(staffUuid);
    log.setResultStatus(resultStatus);
    log.setClientCode(clientId);
    log.setRequestContent("phoneNumber:" + phoneNumber + "|smsCode:" + smsCode + "|checkCode:" + checkCode);
    log.setResponseContent(respMsg);
    log.setUserAgent(req.getHeader("User-Agent"));
    log.setSessionId(ss.getId());
    log.setLocalHost(GetipUtil.LOCAL_HOST);
    this.logConsumer.addLogToQueue(log);
    FlumeLogUtil.writeFlumeLog(FlumeLogUtil.buildInterfaceLog(log, flumeFlag, flumeErrorMsg, SystemLog.ServiceCode.EAM130011));
  }
}

public Object certAuthenticate(String cipher, String random, String clientId, HttpServletRequest req)
{
  long beginTime = System.currentTimeMillis();
  LdapStaffVo staff = null;
  HttpSession ss = req.getSession();
  Object[] r = null;
  String respMsg = null;
  String resultStatus = SystemLog.Result.FAILURE.getDesc();
  String staffAccount = null;
  String staffUuid = null;
  String passport = null;
  FlumeLogBase.SuccessFlag flumeFlag = FlumeLogBase.SuccessFlag.SUCCESS;
  String flumeErrorMsg = null;
  try
  {
    if (StringUtils.isEmpty(cipher))
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "获取认证信息失败!";
      respMsg = "获取认证信息失败!";
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "获取认证信息失败!" });
    }
    if (StringUtils.isEmpty(random))
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "获取认证信息失败!";
      respMsg = "获取认证信息失败!";
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "获取认证信息失败!" });
    }
    SIDPlugin sid = new SIDPlugin(AUTH_SERVER_IP, AUTH_SERVER_PORT);
    

    String licenseKey = AUTH_LICENSE_KEY;
    int ret = sid.Auth_VerifyCTCACert(licenseKey, cipher, random, GetipUtil.getIpAddr(req));
    if (ret != 0)
    {
      String error = sid.getError();
      flumeFlag = FlumeLogBase.SuccessFlag.EXCEPTION;
      flumeErrorMsg = error;
      respMsg = "认证失败! 错误信息：" + error;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "认证失败! 错误信息：" + error });
    }
    passport = sid.getPassport();
    staff = this.ldapServiceImpl.loadStaffByCertNumber(passport);
    if (staff == null)
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "用户不存在";
      respMsg = "用户不存在！";
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "用户不存在或者未同步" });
    }
    staffAccount = staff.getStaffAccount();
    staffUuid = staff.getUuid();
    r = processWithStaff(staff, ss);
    if (((Boolean)r[0]).booleanValue())
    {
      respMsg = "认证成功";
      resultStatus = SystemLog.Result.SUCCESS.getDesc();
      CommonSystemLog log;
      return AjaxUtil.createReturnValueSuccess(new Object[] { r[1] });
    }
    flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
    flumeErrorMsg = (String)r[1];
    respMsg = (String)r[1];
    CommonSystemLog log;
    return AjaxUtil.createReturnValueError(new Object[] { r[1] });
  }
  catch (Exception e)
  {
    Object[] arrayOfObject1;
    flumeFlag = FlumeLogBase.SuccessFlag.EXCEPTION;
    flumeErrorMsg = e.getMessage();
    e.printStackTrace();
    respMsg = e.getMessage();
    CommonSystemLog log;
    return AjaxUtil.createReturnValueError();
  }
  finally
  {
    CommonSystemLog log = new CommonSystemLog();
    log.setServiceCode(SystemLog.ServiceCode.EAM130010.getCode());
    log.setServiceName(SystemLog.ServiceCode.EAM130010.getDesc());
    log.setAuthType("3");
    log.setRequestTime(new Date(beginTime));
    log.setResponseTime(new Date());
    log.setConsumeTime(Long.valueOf(System.currentTimeMillis() - beginTime));
    log.setRequestIp(GetipUtil.getIpAddr(req));
    if ((r != null) && (SystemLog.Result.SUCCESS.getDesc().equals(resultStatus))) {
      log.setOrgUuid((String)r[2]);
    }
    log.setStaffAccount(staffAccount);
    log.setStaffUuid(staffUuid);
    log.setResultStatus(resultStatus);
    log.setClientCode(clientId);
    log.setUserAgent(req.getHeader("User-Agent"));
    log.setRequestContent("cipher:" + cipher + "|random:" + random + "|clientId:" + clientId);
    log.setResponseContent(respMsg);
    log.setSessionId(ss.getId());
    log.setLocalHost(GetipUtil.LOCAL_HOST + GetipUtil.getLocalPort(req));
    this.logConsumer.addLogToQueue(log);
    FlumeLogUtil.writeFlumeLog(FlumeLogUtil.initInterfaceLog(FlumeLogBase.InterfaceInfo.CerAuthenticate, log.getRequestTime(), log.getResponseTime(), flumeFlag, flumeErrorMsg));
  }
}

private void initPwdModifyLog(LdapStaffVo staff)
{
  StaffPwdLogVo log = new StaffPwdLogVo(null, staff.getStaffAccount(), staff.getUserPassord(), new Date());
  StaffPwdCheckUtil.initStaffPwdLog(log);
}

private Object[] processWithStaff(LdapStaffVo staff, HttpSession ss)
{
  List<StaffOrganizationVo> solist = this.ldapServiceImpl
    .queryRelationByStaffId(staff.getStaffId());
  List<OrganizationVo> orgList = LoginUtil.getUserOrganizations(solist);
  

  String orgUuid = null;
  for (OrganizationVo org : orgList) {
    if ("1".equals(org.getRelaCd()))
    {
      orgUuid = org.getUuid();
      break;
    }
  }
  if (orgUuid == null) {
    return new Object[] { Boolean.valueOf(false), "没有找到相关的归属部门！" };
  }
  ss.setAttribute("login_user_uuid", staff.getUuid());
  staff.setOrgUuid(orgUuid);
  ss.setAttribute("login_user_vo", staff);
  ss.setAttribute("login_user_account", staff.getStaffAccount());
  ss.setAttribute("login_organization_uuid", orgUuid);
  



  String url = (String)ss
    .getAttribute("query_string");
  return new Object[] { Boolean.valueOf(true), url, orgUuid };
}

public Object authPhoneVeriCode(String account, String password, String smsCode, String clientId, HttpServletRequest req)
{
  long beginTime = System.currentTimeMillis();
  LdapStaffVo staff = null;
  HttpSession ss = req.getSession();
  Object[] r = null;
  String respMsg = null;
  String resultStatus = SystemLog.Result.FAILURE.getDesc();
  String staffUuid = null;
  FlumeLogBase.SuccessFlag flumeFlag = FlumeLogBase.SuccessFlag.SUCCESS;
  String flumeErrorMsg = null;
  boolean isOpenTimeSwitch = false;
  String phoneNumber = null;
  String adminRandCode = this.commConfigservice.getSwitchCode("adminRandom");
  try
  {
    isOpenTimeSwitch = 
      this.commConfigservice.isOpenSwitch("loginIsOpenTimeSwitch");
    
    long sampleTime = System.currentTimeMillis();
    
    String key = req.getHeader("rnd");
    smsCode = JavaScriptCryptUtil.jsTripleDesDecrypt(smsCode, key);
    clientId = JavaScriptCryptUtil.jsTripleDesDecrypt(clientId, key);
    password = JavaScriptCryptUtil.jsTripleDesDecrypt(password, key);
    String originalPwd = password;
    account = JavaScriptCryptUtil.jsTripleDesDecrypt(account, 
      key);
    

    sampleTime = loggingTimeCost(isOpenTimeSwitch, "[账号密码验证码登录]解密请求参数=", 
      sampleTime);
    

    Object prevPhoneNumberObj = ss
      .getAttribute("PHONE_NUMBER");
    Object prevSmsCodeObj = ss
      .getAttribute("SMS_CODE");
    Object scTimeObj = ss
      .getAttribute("SMS_CODE_TIMESTAMP");
    if ((prevPhoneNumberObj == null) && (!smsCode.equals(adminRandCode)))
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "请先获取短信验证码！";
      respMsg = "请先获取短信验证码！";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "请先获取短信验证码！" });
    }
    if ((prevSmsCodeObj == null) && (!smsCode.equals(adminRandCode)))
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "请先获取短信验证码！";
      respMsg = "请先获取短信验证码！";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "请先获取短信验证码！" });
    }
    if ((scTimeObj == null) && (!smsCode.equals(adminRandCode)))
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "获取的验证码无效！";
      respMsg = "获取的验证码无效！";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "获取的验证码无效！" });
    }
    String prevPhoneNumber = (String)prevPhoneNumberObj;
    String prevSmsCode = (String)prevSmsCodeObj;
    Long scTime = (Long)scTimeObj;
    




    staff = this.ldapServiceImpl.loadStaffByAccount(account);
    if (staff != null)
    {
      if (this.staffLockDaoImpl.isStaffLocked(staff.getUuid()))
      {
        flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
        flumeErrorMsg = "您的帐号已被锁定,请使用\"忘记密码\"功能";
        respMsg = "您的帐号已被锁定,请使用\"忘记密码\"功能";
        long sampleTime9;
        CommonSystemLog log;
        return AjaxUtil.createReturnValue("locked", new Object[] {
          "您的帐号已被锁定,请使用\"忘记密码\"功能" });
      }
      staffUuid = staff.getUuid();
      phoneNumber = staff.getMobilePhone();
    }
    else
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "用户不存在！";
      respMsg = "用户不存在！";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "用户名或者密码错误!" });
    }
    sampleTime = loggingTimeCost(isOpenTimeSwitch, "[账号密码验证码登录]校验用户=", 
      sampleTime);
    if ((!phoneNumber.equals(prevPhoneNumber)) && (!smsCode.equals(adminRandCode)))
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "输入的手机号码不一致！";
      respMsg = "输入的手机号码不一致！";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "输入的手机号码不一致！" });
    }
    sampleTime = loggingTimeCost(isOpenTimeSwitch, "[账号密码验证码登录]校验手机号=", 
      sampleTime);
    if ((scTime != null) && (System.currentTimeMillis() - scTime.longValue() > 300000L) && (!smsCode.equals(adminRandCode)))
    {
      this.staffLockDaoImpl.loginFailed(staff.getUuid(), 
        staff.getStaffAccount());
      respMsg = "短信验证码的有效期已过，请重新获取！";
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "短信验证码的有效期已过，请重新获取！";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "短信验证码的有效期已过，请重新获取！" });
    }
    if ((!smsCode.equals(prevSmsCode)) && (!smsCode.equals(adminRandCode)))
    {
      this.staffLockDaoImpl.loginFailed(staff.getUuid(), 
        staff.getStaffAccount());
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "短信验证码有误！";
      respMsg = "短信验证码有误！";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "短信验证码有误！" });
    }
    sampleTime = loggingTimeCost(isOpenTimeSwitch, 
      "[账号密码验证码登录]校验手机验证码=", sampleTime);
    if (StringUtils.isEmpty(staff.getUserPassord()))
    {
      flumeFlag = FlumeLogBase.SuccessFlag.SUCCESS;
      flumeErrorMsg = "用户初始密码为空,引导致密码修改页面";
      respMsg = "密码为空,请初始化密码";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValue("null-password", new Object[] {
        "密码为空，请初始化密码!" });
    }
    try
    {
      password = SimpleDESCry.encry(password);
    }
    catch (Exception e)
    {
      respMsg = "密码解密异常";
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "密码解密异常";
      arrayOfObject1 = AjaxUtil.createReturnValueError(new Object[] { "密码解密异常" });
      long sampleTime9 = System.currentTimeMillis();
      CommonSystemLog log = new CommonSystemLog();
      log.setServiceCode(SystemLog.ServiceCode.EAM130009.getCode());
      log.setServiceName(SystemLog.ServiceCode.EAM130009.getDesc());
      log.setAuthType("1");
      log.setRequestTime(new Date(beginTime));
      log.setResponseTime(new Date());
      log.setConsumeTime(Long.valueOf(System.currentTimeMillis() - beginTime));
      log.setRequestIp(GetipUtil.getIpAddr(req));
      if ((r != null) && 
        (SystemLog.Result.SUCCESS.getDesc().equals(resultStatus))) {
        log.setOrgUuid((String)r[2]);
      }
      log.setStaffAccount(account);
      log.setStaffUuid(staffUuid);
      log.setResultStatus(resultStatus);
      log.setClientCode(clientId);
      log.setRequestContent("user:" + account + "|password:" + 
        password + "|checkCode:" + smsCode);
      log.setResponseContent(respMsg);
      log.setUserAgent(req.getHeader("User-Agent"));
      log.setSessionId(ss.getId());
      log.setLocalHost(GetipUtil.LOCAL_HOST);
      this.logConsumer.addLogToQueue(log);
      FlumeLogUtil.writeFlumeLog(FlumeLogUtil.buildInterfaceLog(log, 
        flumeFlag, flumeErrorMsg, SystemLog.ServiceCode.EAM130009));
      if (isOpenTimeSwitch) {
        this.logger.error("[账号密码验证码登录]查询组织耗时=" + (
          System.currentTimeMillis() - sampleTime9));
      }
      return arrayOfObject1;
    }
    if (!password.equals(staff.getUserPassord()))
    {
      boolean locked = this.staffLockDaoImpl.loginFailed(staff.getUuid(), 
        staff.getStaffAccount());
      if (locked)
      {
        flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
        flumeErrorMsg = "您的帐号已被锁定,请使用\"忘记密码\"功能";
        respMsg = "您的帐号已被锁定,请使用\"忘记密码\"功能";
        long sampleTime9;
        CommonSystemLog log;
        return AjaxUtil.createReturnValue("locked", new Object[] {
          "您的帐号已被锁定,请使用\"忘记密码\"功能" });
      }
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "密码错误！";
      respMsg = "密码错误！";
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueError(new Object[] { "用户名或者密码错误!" });
    }
    this.staffLockDaoImpl.loginSuccessed(staff.getUuid());
    sampleTime = loggingTimeCost(isOpenTimeSwitch, 
      "[账号密码验证码登录]删除登录失败记录=", sampleTime);
    if ((StaffPwdCheckUtil.isEnableLoginWeakPwdChk()) && 
      (!PwdPolicyUtil.isMatchBasicPattern(originalPwd)))
    {
      flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
      flumeErrorMsg = "密码不符合要求";
      respMsg = "密码不符合要求";
      long sampleTime9;
      CommonSystemLog log;
      return 
        AjaxUtil.createReturnValue(
        "weak-pwd", new Object[] {
        "密码不符合要求" });
    }
    if (StaffPwdCheckUtil.isEnableStaffPwdForceModifyCheck()) {
      if (StaffPwdCheckUtil.countPwdLogByAccount(staff.getStaffAccount()) == 0L)
      {
        initPwdModifyLog(staff);
      }
      else if (StaffPwdCheckUtil.isNeedModifyPwd(staff.getStaffAccount()))
      {
        String msg = String.format(
          "密码已%d天未变更，请修改密码后重新登录！", new Object[] {
          
          Integer.valueOf(StaffPwdCheckUtil.getPwdForceModifyCheckPeriod()) });
        flumeFlag = FlumeLogBase.SuccessFlag.SUCCESS;
        respMsg = msg;
        flumeErrorMsg = msg;
        long sampleTime9;
        CommonSystemLog log;
        return AjaxUtil.createReturnValue(
          "pwd-force-modify", new Object[] { msg });
      }
    }
    sampleTime = loggingTimeCost(isOpenTimeSwitch, 
      "[账号密码验证码登录]校验密码=", sampleTime);
    

    r = processWithStaff(staff, ss);
    if (((Boolean)r[0]).booleanValue())
    {
      resultStatus = SystemLog.Result.SUCCESS.getDesc();
      respMsg = "登录成功";
      
      ss.removeAttribute("PHONE_NUMBER");
      ss.removeAttribute("SMS_CODE");
      ss.removeAttribute("SMS_CODE_TIMESTAMP");
      long sampleTime9;
      CommonSystemLog log;
      return AjaxUtil.createReturnValueSuccess(new Object[] { r[1] });
    }
    flumeFlag = FlumeLogBase.SuccessFlag.BUSINESS_EXCEPTION;
    flumeErrorMsg = (String)r[1];
    respMsg = (String)r[1];
    long sampleTime9;
    CommonSystemLog log;
    return AjaxUtil.createReturnValueError(new Object[] { r[1] });
  }
  catch (Exception e)
  {
    Object[] arrayOfObject1;
    e.printStackTrace();
    flumeFlag = FlumeLogBase.SuccessFlag.EXCEPTION;
    flumeErrorMsg = e.getMessage();
    respMsg = e.getMessage();
    long sampleTime9;
    CommonSystemLog log;
    return AjaxUtil.createReturnValueError();
  }
  finally
  {
    long sampleTime9 = System.currentTimeMillis();
    CommonSystemLog log = new CommonSystemLog();
    log.setServiceCode(SystemLog.ServiceCode.EAM130009.getCode());
    log.setServiceName(SystemLog.ServiceCode.EAM130009.getDesc());
    log.setAuthType("1");
    log.setRequestTime(new Date(beginTime));
    log.setResponseTime(new Date());
    log.setConsumeTime(Long.valueOf(System.currentTimeMillis() - beginTime));
    log.setRequestIp(GetipUtil.getIpAddr(req));
    if ((r != null) && 
      (SystemLog.Result.SUCCESS.getDesc().equals(resultStatus))) {
      log.setOrgUuid((String)r[2]);
    }
    log.setStaffAccount(account);
    log.setStaffUuid(staffUuid);
    log.setResultStatus(resultStatus);
    log.setClientCode(clientId);
    log.setRequestContent("user:" + account + "|password:" + 
      password + "|checkCode:" + smsCode);
    log.setResponseContent(respMsg);
    log.setUserAgent(req.getHeader("User-Agent"));
    log.setSessionId(ss.getId());
    log.setLocalHost(GetipUtil.LOCAL_HOST);
    this.logConsumer.addLogToQueue(log);
    FlumeLogUtil.writeFlumeLog(FlumeLogUtil.buildInterfaceLog(log, 
      flumeFlag, flumeErrorMsg, SystemLog.ServiceCode.EAM130009));
    if (isOpenTimeSwitch) {
      this.logger.error("[账号密码验证码登录]查询组织耗时=" + (
        System.currentTimeMillis() - sampleTime9));
    }
  }
}

private long loggingTimeCost(boolean isOpenTimeSwitch, String msg, long sampleTime1)
{
  if (isOpenTimeSwitch)
  {
    long sampleTime2 = System.currentTimeMillis();
    this.logger.info(msg + (sampleTime2 - sampleTime1));
  }
  return System.currentTimeMillis();
}

public static void main(String[] args)
{
  StringBuffer sb = new StringBuffer(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 进入后台action,开始执行sendSmsCode方法");
  
  System.out.println(sb.toString());
}

public boolean sendSmsByOip(StringBuffer sb, String phoneNumber, String account, String message, String interfaceName)
  throws ClientProtocolException, IOException
{
  sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 短信发送接口：封装短信请求报文开始");
  sb.append("\n");
  String sendSmsUrl = null;
  String outXml = null;
  long beginTime = System.currentTimeMillis();
  String resultStatus = SystemLog.Result.FAILURE.getDesc();
  String result = null;
  String esbHead = null;
  String msgId = null;
  String reqJson = null;
  String urll = "";
  try
  {
    sendSmsUrl = 
      this.commConfigservice.getSwitchCode(AuthConstants.OIP_SENDMESSAGE_URL);
    if (StrUtil.isEmpty(sendSmsUrl))
    {
      this.logger.debug("发送短信的url为空");
      result = "发送短信的url为空";
      CommonSystemLog log;
      return false;
    }
    msgId = EsbHeadUtil.getMsgId(AuthConstants.OIP_SENDER);
    urll = createReqUrl(sendSmsUrl, msgId);
    reqJson = createSmsJsonStr(phoneNumber, message);
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 短信发送接口：封装短信请求报文结束");
    sb.append("\n");
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 短信发送接口：post请求到接口地址");
    sb.append("\n");
    
    outXml = HttpClientUtil.post(urll, reqJson);
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 短信发送接口：post请求结束，获取返回值");
    sb.append("\n");
    result = outXml;
    if ((outXml != null) && (outXml.contains("000")))
    {
      resultStatus = SystemLog.Result.SUCCESS.getDesc();
      CommonSystemLog log;
      return true;
    }
  }
  catch (Exception e)
  {
    e.printStackTrace();
    result = e.getMessage();
    CommonSystemLog log;
    return false;
  }
  finally
  {
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 短信发送接口：开始记录短信日志");
    sb.append("\n");
    CommonSystemLog log = new CommonSystemLog();
    log.setServiceCode(SystemLog.ServiceCode.EAM130001.getCode());
    log.setServiceName(interfaceName);
    log.setAuthType(null);
    log.setRequestTime(new Date(beginTime));
    log.setResponseTime(new Date());
    log.setConsumeTime(Long.valueOf(System.currentTimeMillis() - beginTime));
    log.setRequestIp(null);
    log.setResultStatus(resultStatus);
    log.setClientCode("EAM");
    log.setStaffAccount(account);
    log.setStaffUuid(null);
    log.setUserAgent(null);
    log.setSessionId(msgId);
    log.setLocalHost(GetipUtil.LOCAL_HOST);
    log.setRequestContent("reqJson===" + reqJson);
    log.setResponseContent(result);
    this.logConsumer.addLogToQueue(log);
    sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 短信发送接口：短信日志保存完毕");
    sb.append("\n");
  }
  sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 短信发送接口：开始记录短信日志");
  sb.append("\n");
  CommonSystemLog log = new CommonSystemLog();
  log.setServiceCode(SystemLog.ServiceCode.EAM130001.getCode());
  log.setServiceName(interfaceName);
  log.setAuthType(null);
  log.setRequestTime(new Date(beginTime));
  log.setResponseTime(new Date());
  log.setConsumeTime(Long.valueOf(System.currentTimeMillis() - beginTime));
  log.setRequestIp(null);
  log.setResultStatus(resultStatus);
  log.setClientCode("EAM");
  log.setStaffAccount(account);
  log.setStaffUuid(null);
  log.setUserAgent(null);
  log.setSessionId(msgId);
  log.setLocalHost(GetipUtil.LOCAL_HOST);
  log.setRequestContent("reqJson===" + reqJson);
  log.setResponseContent(result);
  this.logConsumer.addLogToQueue(log);
  sb.append(DateUtil.getYYYYMMDDHHmmssSSS(new Date()) + " 短信发送接口：短信日志保存完毕");
  sb.append("\n");
  
  return false;
}

public String createReqUrl(String url, String msgId)
{
  return url + "&msgId=" + msgId;
}

public String createSmsJsonStr(String phoneNumber, String sentContent)
{
  Gson gson = new Gson();
  SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd H:m:s");
  SimpleDateFormat format2 = new SimpleDateFormat("yyyyMMddHHmmss");
  SmsVo vo = new SmsVo();
  Body body = new Body();
  body.setBusinessId("5430");
  body.setFlowCode("5430_" + format2.format(new Date()));
  body.setFromTel("");
  body.setSentContent(sentContent);
  body.setToTel(phoneNumber);
  body.setTime(format.format(new Date()));
  List<Params> params = new ArrayList();
  Params param = new Params();
  params.add(param);
  body.setParams(param);
  Soo soo = new Soo();
  List<Body> bodys = new ArrayList();
  bodys.add(body);
  soo.setBODY(bodys);
  soo.setSC("setBillInfo");
  SvcCont svcCont = new SvcCont();
  svcCont.setSOO(soo);
  vo.setSvcCont(svcCont);
  gson.toJson(vo);
  
  return gson.toJson(vo);
}*/
}



